<template>
    <div>
        <el-dialog v-model="ViewdialogVisible" width="80%" align-center destroy-on-close draggable>
            <template #header="{ close }">
                <div class="dialog-header flex justify-between items-center">
                    <div>获奖查看</div>
                    <el-icon class="el-icon--left cursor-pointer" @click="close">
                        <CircleCloseFilled color="#fff" />
                    </el-icon>
                </div>
            </template>
            <div>
                <!-- 基本信息 -->
                <div class="bg-white mt-[10px]">
                    <BaseHead>基本信息</BaseHead>
                    <div class="p-[10px]">
                        <el-descriptions title="" :column="2" border label-width="140">
                            <el-descriptions-item label-class-name="gdlable" label="申报计划名称">{{
            ruleForm.name
        }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="奖励名称">{{
                ruleForm.honorName
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="奖励级别">{{
                formatHonorLevelId(ruleForm.honorLevel)
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="申报开始日期">{{
                ruleForm.beginDate
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="申报结束日期">{{
                ruleForm.endDate
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="可转入评审">{{
                ruleForm.honorNumber == 1 ? '是' : "否"
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="自动截止">{{
                ruleForm.isAutoEnd == 1 ? '是' : "否"
                                }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="备注">{{
                                ruleForm.note
                                }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="申报指南">
                                <div v-for="item in ruleForm.fileList" :key="item.id">{{ item.fileName
                                    }}<el-link type="primary" style="margin-left: 8px;"
                                        @click="downloadMet(item.id)">下载</el-link>
                                </div>
                            </el-descriptions-item>
                        </el-descriptions>
                    </div>
                </div>
            </div>
        </el-dialog>
    </div>
</template>
<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
const ViewdialogVisible = defineModel();
const props = defineProps({
    hjjbList: Array,
})
const ruleForm = reactive({
    name: '',
    honorName: '',
    honorLevel: '',
    isReview: '',
    isAutoEnd: '',
    beginDate: '',
    endDate: '',
    note: '',
});
const tableData = reactive([
]);

const formatHonorLevelId = (cellValue) => {
    if (props.hjjbList.length && cellValue) {
        return props.hjjbList.find(item => item.code == cellValue).name
    } else {
        return ''
    }


}

const getRuleForm = (i) => {
    if (i.honorAuthorVOs && i.honorAuthorVOs.length > 0) {
        tableData.length = 0; // 清空数组
        tableData.push(...i.honorAuthorVOs); // 添加新元素

    }
    for (const key in i) {
        ruleForm[key] = i[key];
    }
}

const { proxy } = getCurrentInstance();
const downloadMet = (i) => {
    proxy.$download.common(i)
}
defineExpose({
    getRuleForm
})
</script>
<style lang="scss">
.gdlable {
    width: 140px;
}
</style>
<style scoped lang="scss">
@import url("@/views/achievement/index.scss");

:deep(.el-select--default) {


    .el-select__wrapper.is-disabled {
        background-color: #fff;
        box-shadow: 0 0 0 0px var(--el-select-disabled-border) inset;
        color: #606266;
        cursor: not-allowed;

        .el-select__selected-item {
            color: #606266;
        }
    }

    .el-select__suffix {
        display: none;
    }
}
</style>
